home *** CD-ROM | disk | FTP | other *** search
/ Visual Cafe 3 / Visual Cafe 3.ISO / Vcafe / Main.bin / Graphics.java < prev    next >
Text File  |  1998-09-22  |  51KB  |  1,102 lines

  1. /*
  2.  * @(#)Graphics.java    1.43 98/08/19
  3.  *
  4.  * Copyright 1995-1998 by Sun Microsystems, Inc.,
  5.  * 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.
  6.  * All rights reserved.
  7.  * 
  8.  * This software is the confidential and proprietary information
  9.  * of Sun Microsystems, Inc. ("Confidential Information").  You
  10.  * shall not disclose such Confidential Information and shall use
  11.  * it only in accordance with the terms of the license agreement
  12.  * you entered into with Sun.
  13.  */
  14. package java.awt;
  15.  
  16. import java.io.*;
  17. import java.lang.*;
  18. import java.util.*;
  19. import java.awt.image.ImageObserver;
  20.  
  21. /**
  22.  * The <code>Graphics</code> class is the abstract base class for 
  23.  * all graphics contexts that allow an application to draw onto 
  24.  * components that are realized on various devices, as well as 
  25.  * onto off-screen images.
  26.  * <p>
  27.  * A <code>Graphics</code> object encapsulates state information needed
  28.  * for the basic rendering operations that Java supports.  This
  29.  * state information includes the following properties:
  30.  * <p>
  31.  * <ul>
  32.  * <li>The <code>Component</code> object on which to draw.
  33.  * <li>A translation origin for rendering and clipping coordinates.
  34.  * <li>The current clip.
  35.  * <li>The current color.
  36.  * <li>The current font.
  37.  * <li>The current logical pixel operation function (XOR or Paint).
  38.  * <li>The current XOR alternation color 
  39.  *     (see <a href="#setXORMode"><code>setXORMode</code></a>).
  40.  * </ul>
  41.  * <p>
  42.  * Coordinates are infinitely thin and lie between the pixels of the
  43.  * output device.
  44.  * Operations which draw the outline of a figure operate by traversing
  45.  * an infinitely thin path between pixels with a pixel-sized pen that hangs
  46.  * down and to the right of the anchor point on the path.
  47.  * Operations which fill a figure operate by filling the interior
  48.  * of that infinitely thin path.
  49.  * Operations which render horizontal text render the ascending
  50.  * portion of character glyphs entirely above the baseline coordinate.
  51.  * <p>
  52.  * The graphics pen hangs down and to the right from the path it traverses. 
  53.  * This has the following implications:
  54.  * <p><ul>
  55.  * <li>If you draw a figure that covers a given rectangle, that 
  56.  * figure occupies one extra row of pixels on the right and bottom edges 
  57.  * as compared to filling a figure that is bounded by that same rectangle.
  58.  * <li>If you draw a horizontal line along the same <i>y</i> coordinate as
  59.  * the baseline of a line of text, that line is drawn entirely below
  60.  * the text, except for any descenders.
  61.  * </ul><p>
  62.  * All coordinates which appear as arguments to the methods of this
  63.  * <code>Graphics</code> object are considered relative to the 
  64.  * translation origin of this <code>Graphics</code> object prior to 
  65.  * the invocation of the method.
  66.  * All rendering operations modify only pixels which lie within the
  67.  * area bounded by both the current clip of the graphics context
  68.  * and the extents of the component used to create the 
  69.  * <code>Graphics</code> object.
  70.  * All drawing or writing is done in the current color, 
  71.  * using the current paint mode, and in the current font. 
  72.  * 
  73.  * @version     1.43, 08/19/98
  74.  * @author     Sami Shaio
  75.  * @author     Arthur van Hoff
  76.  * @see     java.awt.Component
  77.  * @see     java.awt.Graphics#clipRect(int, int, int, int)
  78.  * @see     java.awt.Graphics#setColor(java.awt.Color)
  79.  * @see     java.awt.Graphics#setPaintMode()
  80.  * @see     java.awt.Graphics#setXORMode(java.awt.Color)
  81.  * @see     java.awt.Graphics#setFont(java.awt.Font)
  82.  * @since       JDK1.0
  83.  */
  84. public abstract class Graphics {
  85.  
  86.     /**
  87.      * Constructs a new <code>Graphics</code> object.  
  88.      * This constructor is the default contructor for a graphics 
  89.      * context. 
  90.      * <p>
  91.      * Since <code>Graphics</code> is an abstract class, applications 
  92.      * cannot call this constructor directly. Graphics contexts are 
  93.      * obtained from other graphics contexts or are created by calling 
  94.      * <code>getGraphics</code> on a component. 
  95.      * @see        java.awt.Graphics#create()
  96.      * @see        java.awt.Component#getGraphics
  97.      * @since      JDK1.0
  98.      */
  99.     protected Graphics() {
  100.     }
  101.  
  102.     /**
  103.      * Creates a new <code>Graphics</code> object that is 
  104.      * a copy of this <code>Graphics</code> object.
  105.      * @return     a new graphics context that is a copy of 
  106.      *                       this graphics context.
  107.      * @since      JDK1.0
  108.      */
  109.     public abstract Graphics create();
  110.  
  111.     /**
  112.      * Creates a new <code>Graphics</code> object based on this 
  113.      * <code>Graphics</code> object, but with a new translation and clip area.
  114.      * The new <code>Graphics</code> object has its origin 
  115.      * translated to the specified point (<i>x</i>, <i>y</i>). 
  116.      * Its clip area is determined by the intersection of the original
  117.      * clip area with the specified rectangle.  The arguments are all
  118.      * interpreted in the coordinate system of the original 
  119.      * <code>Graphics</code> object. The new graphics context is 
  120.      * identical to the original, except in two respects: 
  121.      * <p>
  122.      * <ul>
  123.      * <li>
  124.      * The new graphics context is translated by (<i>x</i>, <i>y</i>).  
  125.      * That is to say, the point (<code>0</code>, <code>0</code>) in the 
  126.      * new graphics context is the same as (<i>x</i>, <i>y</i>) in 
  127.      * the original graphics context. 
  128.      * <li>
  129.      * The new graphics context has an additional clipping rectangle, in 
  130.      * addition to whatever (translated) clipping rectangle it inherited 
  131.      * from the original graphics context. The origin of the new clipping 
  132.      * rectangle is at (<code>0</code>, <code>0</code>), and its size  
  133.      * is specified by the <code>width</code> and <code>height</code> arguments.
  134.      * </ul>
  135.      * <p>
  136.      * @param      x   the <i>x</i> coordinate.
  137.      * @param      y   the <i>y</i> coordinate.
  138.      * @param      width   the width of the clipping rectangle.
  139.      * @param      height   the height of the clipping rectangle.
  140.      * @return     a new graphics context.
  141.      * @see        java.awt.Graphics#translate
  142.      * @see        java.awt.Graphics#clipRect
  143.      * @since      JDK1.0
  144.      */
  145.     public Graphics create(int x, int y, int width, int height) {
  146.     Graphics g = create();
  147.     g.translate(x, y);
  148.     g.clipRect(0, 0, width, height);
  149.     return g;
  150.     }
  151.  
  152.     /**
  153.      * Translates the origin of the graphics context to the point
  154.      * (<i>x</i>, <i>y</i>) in the current coordinate system. 
  155.      * Modifies this graphics context so that its new origin corresponds 
  156.      * to the point (<i>x</i>, <i>y</i>) in this graphics context's 
  157.      * original coordinate system.  All coordinates used in subsequent 
  158.      * rendering operations on this graphics context will be relative 
  159.      * to this new origin.
  160.      * @param  x   the <i>x</i> coordinate.
  161.      * @param  y   the <i>y</i> coordinate.
  162.      * @since   JDK1.0
  163.      */
  164.     public abstract void translate(int x, int y);
  165.  
  166.     /**
  167.      * Gets this graphics context's current color.
  168.      * @return    this graphics context's current color.
  169.      * @see       java.awt.Color
  170.      * @see       java.awt.Graphics#setColor
  171.      * @since     JDK1.0
  172.      */
  173.     public abstract Color getColor();
  174.  
  175.     /**
  176.      * Sets this graphics context's current color to the specified 
  177.      * color. All subsequent graphics operations using this graphics 
  178.      * context use this specified color. 
  179.      * @param     c   the new rendering color.
  180.      * @see       java.awt.Color
  181.      * @see       java.awt.Graphics#getColor
  182.      * @since     JDK1.0
  183.      */
  184.     public abstract void setColor(Color c);
  185.  
  186.     /**
  187.      * Sets the paint mode of this graphics context to overwrite the 
  188.      * destination with this graphics context's current color. 
  189.      * This sets the logical pixel operation function to the paint or
  190.      * overwrite mode.  All subsequent rendering operations will
  191.      * overwrite the destination with the current color. 
  192.      * @since   JDK1.0
  193.      */
  194.     public abstract void setPaintMode();
  195.  
  196.     /**
  197.      * Sets the paint mode of this graphics context to alternate between 
  198.      * this graphics context's current color and the new specified color. 
  199.      * This specifies that logical pixel operations are performed in the 
  200.      * XOR mode, which alternates pixels between the current color and 
  201.      * a specified XOR color. 
  202.      * <p>
  203.      * When drawing operations are performed, pixels which are the 
  204.      * current color are changed to the specified color, and vice versa. 
  205.      * <p>
  206.      * Pixels that are of colors other than those two colors are changed 
  207.      * in an unpredictable but reversible manner; if the same figure is 
  208.      * drawn twice, then all pixels are restored to their original values. 
  209.      * @param     c1 the XOR alternation color
  210.      * @since     JDK1.0
  211.      */
  212.     public abstract void setXORMode(Color c1);
  213.  
  214.     /**
  215.      * Gets the current font.
  216.      * @return    this graphics context's current font.
  217.      * @see       java.awt.Font
  218.      * @see       java.awt.Graphics#setFont
  219.      * @since     JDK1.0
  220.      */
  221.     public abstract Font getFont();
  222.  
  223.     /**
  224.      * Sets this graphics context's font to the specified font. 
  225.      * All subsequent text operations using this graphics context 
  226.      * use this font. 
  227.      * @param  font   the font.
  228.      * @see     java.awt.Graphics#getFont
  229.      * @see     java.awt.Graphics#drawChars(java.lang.String, int, int)
  230.      * @see     java.awt.Graphics#drawString(byte[], int, int, int, int)
  231.      * @see     java.awt.Graphics#drawBytes(char[], int, int, int, int)
  232.      * @since   JDK1.0
  233.     */
  234.     public abstract void setFont(Font font);
  235.  
  236.     /**
  237.      * Gets the font metrics of the current font.
  238.      * @return    the font metrics of this graphics 
  239.      *                    context's current font.
  240.      * @see       java.awt.Graphics#getFont
  241.      * @see       java.awt.FontMetrics
  242.      * @see       java.awt.Graphics#getFontMetrics(Font)
  243.      * @since     JDK1.0
  244.      */
  245.     public FontMetrics getFontMetrics() {
  246.     return getFontMetrics(getFont());
  247.     }
  248.  
  249.     /**
  250.      * Gets the font metrics for the specified font.
  251.      * @return    the font metrics for the specified font.
  252.      * @param     f the specified font
  253.      * @see       java.awt.Graphics#getFont
  254.      * @see       java.awt.FontMetrics
  255.      * @see       java.awt.Graphics#getFontMetrics()
  256.      * @since     JDK1.0
  257.      */
  258.     public abstract FontMetrics getFontMetrics(Font f);
  259.  
  260.  
  261.     /**
  262.      * Returns the bounding rectangle of the current clipping area.
  263.      * The coordinates in the rectangle are relative to the coordinate
  264.      * system origin of this graphics context.
  265.      * @return      the bounding rectangle of the current clipping area.
  266.      * @see         java.awt.Graphics#getClip
  267.      * @see         java.awt.Graphics#clipRect
  268.      * @see         java.awt.Graphics#setClip(int, int, int, int)
  269.      * @see         java.awt.Graphics#setClip(Shape)
  270.      * @since       JDK1.1
  271.      */
  272.     public abstract Rectangle getClipBounds();
  273.  
  274.     /** 
  275.      * Intersects the current clip with the specified rectangle.
  276.      * The resulting clipping area is the intersection of the current
  277.      * clipping area and the specified rectangle.
  278.      * This method can only be used to make the current clip smaller.
  279.      * To set the current clip larger, use any of the setClip methods.
  280.      * Rendering operations have no effect outside of the clipping area.
  281.      * @param x the x coordinate of the rectangle to intersect the clip with
  282.      * @param y the y coordinate of the rectangle to intersect the clip with
  283.      * @param width the width of the rectangle to intersect the clip with
  284.      * @param height the height of the rectangle to intersect the clip with
  285.      * @see #setClip(int, int, int, int)
  286.      * @see #setClip(Shape)
  287.      */
  288.     public abstract void clipRect(int x, int y, int width, int height);
  289.  
  290.     /**
  291.      * Sets the current clip to the rectangle specified by the given
  292.      * coordinates.
  293.      * Rendering operations have no effect outside of the clipping area.
  294.      * @param       x the <i>x</i> coordinate of the new clip rectangle.
  295.      * @param       y the <i>y</i> coordinate of the new clip rectangle.
  296.      * @param       width the width of the new clip rectangle.
  297.      * @param       height the height of the new clip rectangle.
  298.      * @see         java.awt.Graphics#clipRect
  299.      * @see         java.awt.Graphics#setClip(Shape)
  300.      * @since       JDK1.1
  301.      */
  302.     public abstract void setClip(int x, int y, int width, int height);
  303.  
  304.     /**
  305.      * Gets the current clipping area.
  306.      * @return      a <code>Shape</code> object representing the 
  307.      *                      current clipping area.
  308.      * @see         java.awt.Graphics#getClipBounds
  309.      * @see         java.awt.Graphics#clipRect
  310.      * @see         java.awt.Graphics#setClip(int, int, int, int)
  311.      * @see         java.awt.Graphics#setClip(Shape)
  312.      * @since       JDK1.1
  313.      */
  314.     public abstract Shape getClip();
  315.  
  316.     /**
  317.      * Sets the current clipping area to an arbitrary clip shape.
  318.      * Not all objects which implement the <code>Shape</code> 
  319.      * interface can be used to set the clip.  The only 
  320.      * <code>Shape</code> objects which are guaranteed to be 
  321.      * supported are <code>Shape</code> objects which are
  322.      * obtained via the <code>getClip</code> method and via 
  323.      * <code>Rectangle</code> objects.
  324.      * @see         java.awt.Graphics#getClip()
  325.      * @see         java.awt.Graphics#clipRect
  326.      * @see         java.awt.Graphics#setClip(int, int, int, int)
  327.      * @since       JDK1.1
  328.      */
  329.     public abstract void setClip(Shape clip);
  330.  
  331.     /**
  332.      * Copies an area of the component by a distance specified by 
  333.      * <code>dx</code> and <code>dy</code>. From the point specified
  334.      * by <code>x</code> and <code>y</code>, this method
  335.      * copies downwards and to the right.  To copy an area of the 
  336.      * component to the left or upwards, specify a negative value for 
  337.      * <code>dx</code> or <code>dy</code>.
  338.      * If a portion of the source rectangle lies outside the bounds 
  339.      * of the component, or is obscured by another window or component, 
  340.      * <code>copyArea</code> will be unable to copy the associated
  341.      * pixels. The area that is omitted can be refreshed by calling 
  342.      * the component's <code>paint</code> method.
  343.      * @param       x the <i>x</i> coordinate of the source rectangle.
  344.      * @param       y the <i>y</i> coordinate of the source rectangle.
  345.      * @param       width the width of the source rectangle.
  346.      * @param       height the height of the source rectangle.
  347.      * @param       dx the horizontal distance to copy the pixels.
  348.      * @param       dy the vertical distance to copy the pixels.
  349.      * @since       JDK1.0
  350.      */
  351.     public abstract void copyArea(int x, int y, int width, int height,
  352.                   int dx, int dy);
  353.  
  354.     /** 
  355.      * Draws a line, using the current color, between the points 
  356.      * <code>(x1, y1)</code> and <code>(x2, y2)</code> 
  357.      * in this graphics context's coordinate system. 
  358.      * @param   x1  the first point's <i>x</i> coordinate.
  359.      * @param   y1  the first point's <i>y</i> coordinate.
  360.      * @param   x2  the second point's <i>x</i> coordinate.
  361.      * @param   y2  the second point's <i>y</i> coordinate.
  362.      * @since   JDK1.0
  363.      */
  364.     public abstract void drawLine(int x1, int y1, int x2, int y2);
  365.  
  366.     /** 
  367.      * Fills the specified rectangle. 
  368.      * The left and right edges of the rectangle are at 
  369.      * <code>x</code> and <code>x + width - 1</code>. 
  370.      * The top and bottom edges are at 
  371.      * <code>y</code> and <code>y + height - 1</code>. 
  372.      * The resulting rectangle covers an area 
  373.      * <code>width</code> pixels wide by 
  374.      * <code>height</code> pixels tall.
  375.      * The rectangle is filled using the graphics context's current color. 
  376.      * @param         x   the <i>x</i> coordinate 
  377.      *                         of the rectangle to be filled.
  378.      * @param         y   the <i>y</i> coordinate 
  379.      *                         of the rectangle to be filled.
  380.      * @param         width   the width of the rectangle to be filled.
  381.      * @param         height   the height of the rectangle to be filled.
  382.      * @see           java.awt.Graphics#fillRect
  383.      * @see           java.awt.Graphics#clearRect
  384.      * @since         JDK1.0
  385.      */
  386.     public abstract void fillRect(int x, int y, int width, int height);
  387.  
  388.     /** 
  389.      * Draws the outline of the specified rectangle. 
  390.      * The left and right edges of the rectangle are at 
  391.      * <code>x</code> and <code>x + width</code>. 
  392.      * The top and bottom edges are at 
  393.      * <code>y</code> and <code>y + height</code>. 
  394.      * The rectangle is drawn using the graphics context's current color.
  395.      * @param         x   the <i>x</i> coordinate 
  396.      *                         of the rectangle to be drawn.
  397.      * @param         y   the <i>y</i> coordinate 
  398.      *                         of the rectangle to be drawn.
  399.      * @param         width   the width of the rectangle to be drawn.
  400.      * @param         height   the height of the rectangle to be drawn.
  401.      * @see          java.awt.Graphics#fillRect
  402.      * @see          java.awt.Graphics#clearRect
  403.      * @since        JDK1.0
  404.      */
  405.     public void drawRect(int x, int y, int width, int height) {
  406.     if ((width < 0) || (height < 0)) {
  407.         return;
  408.     }
  409.  
  410.     if (height == 0 || width == 0) {
  411.         drawLine(x, y, x + width, y + height);
  412.     } else {
  413.         drawLine(x, y, x + width - 1, y);
  414.         drawLine(x + width, y, x + width, y + height - 1);
  415.         drawLine(x + width, y + height, x + 1, y + height);
  416.         drawLine(x, y + height, x, y + 1);
  417.     }
  418.     }
  419.     
  420.     /** 
  421.      * Clears the specified rectangle by filling it with the background
  422.      * color of the current drawing surface. This operation does not 
  423.      * use the current paint mode. 
  424.      * <p>
  425.      * Beginning with Java 1.1, the background color 
  426.      * of offscreen images may be system dependent. Applications should 
  427.      * use <code>setColor</code> followed by <code>fillRect</code> to 
  428.      * ensure that an offscreen image is cleared to a specific color. 
  429.      * @param       x the <i>x</i> coordinate of the rectangle to clear.
  430.      * @param       y the <i>y</i> coordinate of the rectangle to clear.
  431.      * @param       width the width of the rectangle to clear.
  432.      * @param       height the height of the rectangle to clear.
  433.      * @see         java.awt.Graphics#fillRect(int, int, int, int)
  434.      * @see         java.awt.Graphics#drawRect
  435.      * @see         java.awt.Graphics#setColor(java.awt.Color)
  436.      * @see         java.awt.Graphics#setPaintMode
  437.      * @see         java.awt.Graphics#setXORMode(java.awt.Color)
  438.      * @since       JDK1.0
  439.      */
  440.     public abstract void clearRect(int x, int y, int width, int height);
  441.  
  442.     /** 
  443.      * Draws an outlined round-cornered rectangle using this graphics 
  444.      * context's current color. The left and right edges of the rectangle 
  445.      * are at <code>x</code> and <code>x + width</code>, 
  446.      * respectively. The top and bottom edges of the rectangle are at 
  447.      * <code>y</code> and <code>y + height</code>. 
  448.      * @param      x the <i>x</i> coordinate of the rectangle to be drawn.
  449.      * @param      y the <i>y</i> coordinate of the rectangle to be drawn.
  450.      * @param      width the width of the rectangle to be drawn.
  451.      * @param      height the height of the rectangle to be drawn.
  452.      * @param      arcWidth the horizontal diameter of the arc 
  453.      *                    at the four corners.
  454.      * @param      arcHeight the vertical diameter of the arc 
  455.      *                    at the four corners.
  456.      * @see        java.awt.Graphics#fillRoundRect
  457.      * @since      JDK1.0
  458.      */
  459.     public abstract void drawRoundRect(int x, int y, int width, int height,
  460.                        int arcWidth, int arcHeight);
  461.  
  462.     /** 
  463.      * Fills the specified rounded corner rectangle with the current color.
  464.      * The left and right edges of the rectangle 
  465.      * are at <code>x</code> and <code>x + width - 1</code>, 
  466.      * respectively. The top and bottom edges of the rectangle are at 
  467.      * <code>y</code> and <code>y + height - 1</code>. 
  468.      * @param       x the <i>x</i> coordinate of the rectangle to be filled.
  469.      * @param       y the <i>y</i> coordinate of the rectangle to be filled.
  470.      * @param       width the width of the rectangle to be filled.
  471.      * @param       height the height of the rectangle to be filled.
  472.      * @param       arcWidth the horizontal diameter 
  473.      *                     of the arc at the four corners.
  474.      * @param       arcHeight the vertical diameter 
  475.      *                     of the arc at the four corners.
  476.      * @see         java.awt.Graphics#drawRoundRect
  477.      * @since       JDK1.0
  478.      */
  479.     public abstract void fillRoundRect(int x, int y, int width, int height,
  480.                        int arcWidth, int arcHeight);
  481.  
  482.     /**
  483.      * Draws a 3-D highlighted outline of the specified rectangle.
  484.      * The edges of the rectangle are highlighted so that they
  485.      * appear to be beveled and lit from the upper left corner.
  486.      * <p>
  487.      * The colors used for the highlighting effect are determined 
  488.      * based on the current color.
  489.      * The resulting rectangle covers an area that is 
  490.      * <code>width + 1</code> pixels wide
  491.      * by <code>height + 1</code> pixels tall.
  492.      * @param       x the <i>x</i> coordinate of the rectangle to be drawn.
  493.      * @param       y the <i>y</i> coordinate of the rectangle to be drawn.
  494.      * @param       width the width of the rectangle to be drawn.
  495.      * @param       height the height of the rectangle to be drawn.
  496.      * @param       raised a boolean that determines whether the rectangle
  497.      *                      appears to be raised above the surface 
  498.      *                      or sunk into the surface.
  499.      * @see         java.awt.Graphics#fill3DRect
  500.      * @since       JDK1.0
  501.      */
  502.     public void draw3DRect(int x, int y, int width, int height,
  503.                boolean raised) {
  504.     Color c = getColor();
  505.     Color brighter = c.brighter();
  506.     Color darker = c.darker();
  507.  
  508.     setColor(raised ? brighter : darker);
  509.     drawLine(x, y, x, y + height);
  510.     drawLine(x + 1, y, x + width - 1, y);
  511.     setColor(raised ? darker : brighter);
  512.     drawLine(x + 1, y + height, x + width, y + height);
  513.     drawLine(x + width, y, x + width, y + height - 1);
  514.     setColor(c);
  515.     }    
  516.  
  517.     /**
  518.      * Paints a 3-D highlighted rectangle filled with the current color.
  519.      * The edges of the rectangle will be highlighted so that it appears
  520.      * as if the edges were beveled and lit from the upper left corner.
  521.      * The colors used for the highlighting effect will be determined from
  522.      * the current color.
  523.      * @param       x the <i>x</i> coordinate of the rectangle to be filled.
  524.      * @param       y the <i>y</i> coordinate of the rectangle to be filled.
  525.      * @param       width the width of the rectangle to be filled.
  526.      * @param       height the height of the rectangle to be filled.
  527.      * @param       raised a boolean value that determines whether the 
  528.      *                      rectangle appears to be raised above the surface 
  529.      *                      or etched into the surface.
  530.      * @see         java.awt.Graphics#draw3DRect
  531.      * @since       JDK1.0
  532.      */
  533.     public void fill3DRect(int x, int y, int width, int height,
  534.                boolean raised) {
  535.     Color c = getColor();
  536.     Color brighter = c.brighter();
  537.     Color darker = c.darker();
  538.  
  539.     if (!raised) {
  540.         setColor(darker);
  541.     }
  542.     fillRect(x+1, y+1, width-2, height-2);
  543.     setColor(raised ? brighter : darker);
  544.     drawLine(x, y, x, y + height - 1);
  545.     drawLine(x + 1, y, x + width - 2, y);
  546.     setColor(raised ? darker : brighter);
  547.     drawLine(x + 1, y + height - 1, x + width - 1, y + height - 1);
  548.     drawLine(x + width - 1, y, x + width - 1, y + height - 2);
  549.     setColor(c);
  550.     }    
  551.  
  552.     /** 
  553.      * Draws the outline of an oval.
  554.      * The result is a circle or ellipse that fits within the 
  555.      * rectangle specified by the <code>x</code>, <code>y</code>, 
  556.      * <code>width</code>, and <code>height</code> arguments. 
  557.      * <p> 
  558.      * The oval covers an area that is 
  559.      * <code>width + 1</code> pixels wide 
  560.      * and <code>height + 1<code> pixels tall. 
  561.      * @param       x the <i>x</i> coordinate of the upper left 
  562.      *                     corner of the oval to be drawn.
  563.      * @param       y the <i>y</i> coordinate of the upper left 
  564.      *                     corner of the oval to be drawn.
  565.      * @param       width the width of the oval to be drawn.
  566.      * @param       height the height of the oval to be drawn.
  567.      * @see         java.awt.Graphics#fillOval
  568.      * @since       JDK1.0
  569.      */
  570.     public abstract void drawOval(int x, int y, int width, int height);
  571.  
  572.     /** 
  573.      * Fills an oval bounded by the specified rectangle with the
  574.      * current color.
  575.      * @param       x the <i>x</i> coordinate of the upper left corner 
  576.      *                     of the oval to be filled.
  577.      * @param       y the <i>y</i> coordinate of the upper left corner 
  578.      *                     of the oval to be filled.
  579.      * @param       width the width of the oval to be filled.
  580.      * @param       height the height of the oval to be filled.
  581.      * @see         java.awt.Graphics#drawOval
  582.      * @since       JDK1.0
  583.      */
  584.     public abstract void fillOval(int x, int y, int width, int height);
  585.  
  586.     /**
  587.      * Draws the outline of a circular or elliptical arc 
  588.      * covering the specified rectangle.
  589.      * <p>
  590.      * The resulting arc begins at <code>startAngle</code> and extends  
  591.      * for <code>arcAngle</code> degrees, using the current color.
  592.      * Angles are interpreted such that 0 degrees 
  593.      * is at the 3 o'clock position. 
  594.      * A positive value indicates a counter-clockwise rotation
  595.      * while a negative value indicates a clockwise rotation.
  596.      * <p>
  597.      * The center of the arc is the center of the rectangle whose origin 
  598.      * is (<i>x</i>, <i>y</i>) and whose size is specified by the 
  599.      * <code>width</code> and <code>height</code> arguments. 
  600.      * <p>
  601.      * The resulting arc covers an area 
  602.      * <code>width + 1</code> pixels wide
  603.      * by <code>height + 1</code> pixels tall.
  604.      * @param        x the <i>x</i> coordinate of the 
  605.      *                    upper-left corner of the arc to be drawn.
  606.      * @param        y the <i>y</i>  coordinate of the 
  607.      *                    upper-left corner of the arc to be drawn.
  608.      * @param        width the width of the arc to be drawn.
  609.      * @param        height the height of the arc to be drawn.
  610.      * @param        startAngle the beginning angle.
  611.      * @param        arcAngle the angular extent of the arc, 
  612.      *                    relative to the start angle.
  613.      * @see         java.awt.Graphics#fillArc
  614.      * @since       JDK1.0
  615.      */
  616.     public abstract void drawArc(int x, int y, int width, int height,
  617.                  int startAngle, int arcAngle);
  618.  
  619.     /** 
  620.      * Fills a circular or elliptical arc covering the specified rectangle.
  621.      * <p>
  622.      * The resulting arc begins at <code>startAngle</code> and extends  
  623.      * for <code>arcAngle</code> degrees.
  624.      * Angles are interpreted such that 0 degrees 
  625.      * is at the 3 o'clock position. 
  626.      * A positive value indicates a counter-clockwise rotation
  627.      * while a negative value indicates a clockwise rotation.
  628.      * <p>
  629.      * The center of the arc is the center of the rectangle whose origin 
  630.      * is (<i>x</i>, <i>y</i>) and whose size is specified by the 
  631.      * <code>width</code> and <code>height</code> arguments. 
  632.      * <p>
  633.      * The resulting arc covers an area 
  634.      * <code>width + 1</code> pixels wide
  635.      * by <code>height + 1</code> pixels tall.
  636.      * @param        x the <i>x</i> coordinate of the 
  637.      *                    upper-left corner of the arc to be filled.
  638.      * @param        y the <i>y</i>  coordinate of the 
  639.      *                    upper-left corner of the arc to be filled.
  640.      * @param        width the width of the arc to be filled.
  641.      * @param        height the height of the arc to be filled.
  642.      * @param        startAngle the beginning angle.
  643.      * @param        arcAngle the angular extent of the arc, 
  644.      *                    relative to the start angle.
  645.      * @see         java.awt.Graphics#drawArc
  646.      * @since       JDK1.0
  647.      */
  648.     public abstract void fillArc(int x, int y, int width, int height,
  649.                  int startAngle, int arcAngle);
  650.  
  651.     /** 
  652.      * Draws a sequence of connected lines defined by 
  653.      * arrays of <i>x</i> and <i>y</i> coordinates. 
  654.      * Each pair of (<i>x</i>, <i>y</i>) coordinates defines a point.
  655.      * The figure is not closed if the first point 
  656.      * differs from the last point.
  657.      * @param       xPoints an array of <i>x</i> points
  658.      * @param       yPoints an array of <i>y</i> points
  659.      * @param       nPoints the total number of points
  660.      * @see         java.awt.Graphics#drawPolygon(int[], int[], int)
  661.      * @since       JDK1.1
  662.      */
  663.     public abstract void drawPolyline(int xPoints[], int yPoints[],
  664.                       int nPoints);
  665.  
  666.     /** 
  667.      * Draws a closed polygon defined by 
  668.      * arrays of <i>x</i> and <i>y</i> coordinates. 
  669.      * Each pair of (<i>x</i>, <i>y</i>) coordinates defines a point.
  670.      * <p>
  671.      * This method draws the polygon defined by <code>nPoint</code> line 
  672.      * segments, where the first <code>nPoint - 1</code> 
  673.      * line segments are line segments from 
  674.      * <code>(xPoints[i - 1], yPoints[i - 1])</code> 
  675.      * to <code>(xPoints[i], yPoints[i])</code>, for 
  676.      * 1 ≤ <i>i</i> ≤ <code>nPoints</code>.  
  677.      * The figure is automatically closed by drawing a line connecting
  678.      * the final point to the first point, if those points are different.
  679.      * @param        xPoints   a an array of <code>x</code> coordinates.
  680.      * @param        yPoints   a an array of <code>y</code> coordinates.
  681.      * @param        nPoints   a the total number of points.
  682.      * @see          java.awt.Graphics#fillPolygon
  683.      * @see          java.awt.Graphics#drawPolyline
  684.      * @since        JDK1.0
  685.      */
  686.     public abstract void drawPolygon(int xPoints[], int yPoints[],
  687.                      int nPoints);
  688.  
  689.     /** 
  690.      * Draws the outline of a polygon defined by the specified 
  691.      * <code>Polygon</code> object. 
  692.      * @param        p the polygon to draw.
  693.      * @see          java.awt.Graphics#fillPolygon
  694.      * @see          java.awt.Graphics#drawPolyline
  695.      * @since        JDK1.0
  696.      */
  697.     public void drawPolygon(Polygon p) {
  698.     drawPolygon(p.xpoints, p.ypoints, p.npoints);
  699.     }
  700.  
  701.     /** 
  702.      * Fills a closed polygon defined by 
  703.      * arrays of <i>x</i> and <i>y</i> coordinates. 
  704.      * <p>
  705.      * This method draws the polygon defined by <code>nPoint</code> line 
  706.      * segments, where the first <code>nPoint - 1</code> 
  707.      * line segments are line segments from 
  708.      * <code>(xPoints[i - 1], yPoints[i - 1])</code> 
  709.      * to <code>(xPoints[i], yPoints[i])</code>, for 
  710.      * 1 ≤ <i>i</i> ≤ <code>nPoints</code>.  
  711.      * The figure is automatically closed by drawing a line connecting
  712.      * the final point to the first point, if those points are different.
  713.      * <p>
  714.      * The area inside the polygon is defined using an 
  715.      * even-odd fill rule, also known as the alternating rule.
  716.      * @param        xPoints   a an array of <code>x</code> coordinates.
  717.      * @param        yPoints   a an array of <code>y</code> coordinates.
  718.      * @param        nPoints   a the total number of points.
  719.      * @see          java.awt.Graphics#drawPolygon(int[], int[], int)
  720.      * @since        JDK1.0
  721.      */
  722.     public abstract void fillPolygon(int xPoints[], int yPoints[],
  723.                      int nPoints);
  724.  
  725.     /** 
  726.      * Fills the polygon defined by the specified Polygon object with
  727.      * the graphics context's current color. 
  728.      * <p>
  729.      * The area inside the polygon is defined using an 
  730.      * even-odd fill rule, also known as the alternating rule.
  731.      * @param        p the polygon to fill.
  732.      * @see          java.awt.Graphics#drawPolygon(int[], int[], int)
  733.      * @since        JDK1.0
  734.      */
  735.     public void fillPolygon(Polygon p) {
  736.     fillPolygon(p.xpoints, p.ypoints, p.npoints);
  737.     }
  738.  
  739.     /** 
  740.      * Draws the text given by the specified string, using this 
  741.      * graphics context's current font and color. The baseline of the 
  742.      * first character is at position (<i>x</i>, <i>y</i>) in this 
  743.      * graphics context's coordinate system. 
  744.      * @param       str      the string to be drawn.
  745.      * @param       x        the <i>x</i> coordinate.
  746.      * @param       y        the <i>y</i> coordinate.
  747.      * @see         java.awt.Graphics#drawBytes
  748.      * @see         java.awt.Graphics#drawChars
  749.      * @since       JDK1.0
  750.      */
  751.     public abstract void drawString(String str, int x, int y);
  752.  
  753.     /** 
  754.      * Draws the text given by the specified character array, using this 
  755.      * graphics context's current font and color. The baseline of the 
  756.      * first character is at position (<i>x</i>, <i>y</i>) in this 
  757.      * graphics context's coordinate system. 
  758.      * @param data the array of characters to be drawn
  759.      * @param offset the start offset in the data
  760.      * @param length the number of characters to be drawn
  761.      * @param x the <i>x</i> coordinate of the baseline of the text
  762.      * @param y the <i>y</i> coordinate of the baseline of the text
  763.      * @see         java.awt.Graphics#drawBytes
  764.      * @see         java.awt.Graphics#drawString
  765.      * @since       JDK1.0
  766.      */
  767.     public void drawChars(char data[], int offset, int length, int x, int y) {
  768.     drawString(new String(data, offset, length), x, y);
  769.     }
  770.  
  771.     /** 
  772.      * Draws the text given by the specified byte array, using this 
  773.      * graphics context's current font and color. The baseline of the 
  774.      * first character is at position (<i>x</i>, <i>y</i>) in this 
  775.      * graphics context's coordinate system.
  776.      * @param data the data to be drawn
  777.      * @param offset the start offset in the data
  778.      * @param length the number of bytes that are drawn
  779.      * @param x the <i>x</i> coordinate of the baseline of the text
  780.      * @param y the <i>y</i> coordinate of the baseline of the text
  781.      * @see         java.awt.Graphics#drawChars
  782.      * @see         java.awt.Graphics#drawString
  783.      * @since       JDK1.0
  784.      */
  785.     public void drawBytes(byte data[], int offset, int length, int x, int y) {
  786.     drawString(new String(data, 0, offset, length), x, y);
  787.     }
  788.  
  789.     /** 
  790.      * Draws as much of the specified image as is currently available.
  791.      * The image is drawn with its top-left corner at 
  792.      * (<i>x</i>, <i>y</i>) in this graphics context's coordinate 
  793.      * space. Transparent pixels in the image do not affect whatever 
  794.      * pixels are already there. 
  795.      * <p>
  796.      * This method returns immediately in all cases, even if the
  797.      * complete image has not yet been loaded, and it has not been dithered 
  798.      * and converted for the current output device.
  799.      * <p>
  800.      * If the image has not yet been completely loaded, then
  801.      * <code>drawImage</code> returns <code>false</code>. As more of
  802.      * the image becomes available, the process that draws the image notifies 
  803.      * the specified image observer.
  804.      * @param    img the specified image to be drawn.
  805.      * @param    x   the <i>x</i> coordinate.
  806.      * @param    y   the <i>y</i> coordinate.
  807.      * @param    observer    object to be notified as more of 
  808.      *                          the image is converted.
  809.      * @see      java.awt.Image
  810.      * @see      java.awt.image.ImageObserver
  811.      * @see      java.awt.image.ImageObserver#imageUpdate(java.awt.Image, int, int, int, int, int)
  812.      * @since    JDK1.0
  813.      */
  814.     public abstract boolean drawImage(Image img, int x, int y, 
  815.                       ImageObserver observer);
  816.  
  817.     /**
  818.      * Draws as much of the specified image as has already been scaled
  819.      * to fit inside the specified rectangle.
  820.      * <p>
  821.      * The image is drawn inside the specified rectangle of this 
  822.      * graphics context's coordinate space, and is scaled if 
  823.      * necessary. Transparent pixels do not affect whatever pixels
  824.      * are already there. 
  825.      * <p>
  826.      * This method returns immediately in all cases, even if the
  827.      * entire image has not yet been scaled, dithered, and converted
  828.      * for the current output device.
  829.      * If the current output representation is not yet complete, then
  830.      * <code>drawImage</code> returns <code>false</code>. As more of
  831.      * the image becomes available, the process that draws the image notifies 
  832.      * the image observer by calling its <code>imageUpdate</code> method.
  833.      * <p>
  834.      * A scaled version of an image will not necessarily be
  835.      * available immediately just because an unscaled version of the
  836.      * image has been constructed for this output device.  Each size of
  837.      * the image may be cached separately and generated from the original
  838.      * data in a separate image production sequence.
  839.      * @param    img    the specified image to be drawn.
  840.      * @param    x      the <i>x</i> coordinate.
  841.      * @param    y      the <i>y</i> coordinate.
  842.      * @param    width  the width of the rectangle.
  843.      * @param    height the height of the rectangle.
  844.      * @param    observer    object to be notified as more of 
  845.      *                          the image is converted.
  846.      * @see      java.awt.Image
  847.      * @see      java.awt.image.ImageObserver
  848.      * @see      java.awt.image.ImageObserver#imageUpdate(java.awt.Image, int, int, int, int, int)
  849.      * @since    JDK1.0
  850.      */
  851.     public abstract boolean drawImage(Image img, int x, int y,
  852.                       int width, int height, 
  853.                       ImageObserver observer);
  854.     
  855.     /** 
  856.      * Draws as much of the specified image as is currently available.
  857.      * The image is drawn with its top-left corner at 
  858.      * (<i>x</i>, <i>y</i>) in this graphics context's coordinate 
  859.      * space.  Transparent pixels are drawn in the specified
  860.      * background color.
  861.      * <p> 
  862.      * This operation is equivalent to filling a rectangle of the
  863.      * width and height of the specified image with the given color and then
  864.      * drawing the image on top of it, but possibly more efficient.
  865.      * <p>
  866.      * This method returns immediately in all cases, even if the
  867.      * complete image has not yet been loaded, and it has not been dithered 
  868.      * and converted for the current output device.
  869.      * <p>
  870.      * If the image has not yet been completely loaded, then
  871.      * <code>drawImage</code> returns <code>false</code>. As more of
  872.      * the image becomes available, the process that draws the image notifies 
  873.      * the specified image observer.
  874.      * @param    img    the specified image to be drawn.
  875.      * @param    x      the <i>x</i> coordinate.
  876.      * @param    y      the <i>y</i> coordinate.
  877.      * @param    bgcolor the background color to paint under the
  878.      *                         non-opaque portions of the image.
  879.      * @param    observer    object to be notified as more of 
  880.      *                          the image is converted.
  881.      * @see      java.awt.Image
  882.      * @see      java.awt.image.ImageObserver
  883.      * @see      java.awt.image.ImageObserver#imageUpdate(java.awt.Image, int, int, int, int, int)
  884.      * @since    JDK1.0
  885.      */
  886.     public abstract boolean drawImage(Image img, int x, int y, 
  887.                       Color bgcolor,
  888.                       ImageObserver observer);
  889.  
  890.     /**
  891.      * Draws as much of the specified image as has already been scaled
  892.      * to fit inside the specified rectangle.
  893.      * <p>
  894.      * The image is drawn inside the specified rectangle of this 
  895.      * graphics context's coordinate space, and is scaled if 
  896.      * necessary. Transparent pixels are drawn in the specified
  897.      * background color. 
  898.      * This operation is equivalent to filling a rectangle of the
  899.      * width and height of the specified image with the given color and then
  900.      * drawing the image on top of it, but possibly more efficient.
  901.      * <p>
  902.      * This method returns immediately in all cases, even if the
  903.      * entire image has not yet been scaled, dithered, and converted
  904.      * for the current output device.
  905.      * If the current output representation is not yet complete then
  906.      * <code>drawImage</code> returns <code>false</code>. As more of
  907.      * the image becomes available, the process that draws the image notifies 
  908.      * the specified image observer.
  909.      * <p>
  910.      * A scaled version of an image will not necessarily be
  911.      * available immediately just because an unscaled version of the
  912.      * image has been constructed for this output device.  Each size of
  913.      * the image may be cached separately and generated from the original
  914.      * data in a separate image production sequence.
  915.      * @param    img       the specified image to be drawn.
  916.      * @param    x         the <i>x</i> coordinate.
  917.      * @param    y         the <i>y</i> coordinate.
  918.      * @param    width     the width of the rectangle.
  919.      * @param    height    the height of the rectangle.
  920.      * @param    bgcolor   the background color to paint under the
  921.      *                         non-opaque portions of the image.
  922.      * @param    observer    object to be notified as more of 
  923.      *                          the image is converted.
  924.      * @see      java.awt.Image
  925.      * @see      java.awt.image.ImageObserver
  926.      * @see      java.awt.image.ImageObserver#imageUpdate(java.awt.Image, int, int, int, int, int)
  927.      * @since    JDK1.0
  928.      */
  929.     public abstract boolean drawImage(Image img, int x, int y,
  930.                       int width, int height, 
  931.                       Color bgcolor,
  932.                       ImageObserver observer);
  933.     
  934.     /**
  935.      * Draws as much of the specified area of the specified image as is
  936.      * currently available, scaling it on the fly to fit inside the
  937.      * specified area of the destination drawable surface. Transparent pixels 
  938.      * do not affect whatever pixels are already there.
  939.      * <p>
  940.      * This method returns immediately in all cases, even if the
  941.      * image area to be drawn has not yet been scaled, dithered, and converted
  942.      * for the current output device.
  943.      * If the current output representation is not yet complete then
  944.      * <code>drawImage</code> returns <code>false</code>. As more of
  945.      * the image becomes available, the process that draws the image notifies 
  946.      * the specified image observer.
  947.      * <p>
  948.      * This method always uses the unscaled version of the image
  949.      * to render the scaled rectangle and performs the required
  950.      * scaling on the fly. It does not use a cached, scaled version
  951.      * of the image for this operation. Scaling of the image from source
  952.      * to destination is performed such that the first coordinate
  953.      * of the source rectangle is mapped to the first coordinate of
  954.      * the destination rectangle, and the second source coordinate is
  955.      * mapped to the second destination coordinate. The subimage is
  956.      * scaled and flipped as needed to preserve those mappings.
  957.      * @param       img the specified image to be drawn
  958.      * @param       dx1 the <i>x</i> coordinate of the first corner of the
  959.      *                    destination rectangle.
  960.      * @param       dy1 the <i>y</i> coordinate of the first corner of the
  961.      *                    destination rectangle.
  962.      * @param       dx2 the <i>x</i> coordinate of the second corner of the
  963.      *                    destination rectangle.
  964.      * @param       dy2 the <i>y</i> coordinate of the second corner of the
  965.      *                    destination rectangle.
  966.      * @param       sx1 the <i>x</i> coordinate of the first corner of the
  967.      *                    source rectangle.
  968.      * @param       sy1 the <i>y</i> coordinate of the first corner of the
  969.      *                    source rectangle.
  970.      * @param       sx2 the <i>x</i> coordinate of the second corner of the
  971.      *                    source rectangle.
  972.      * @param       sy2 the <i>y</i> coordinate of the second corner of the
  973.      *                    source rectangle.
  974.      * @param       observer object to be notified as more of the image is
  975.      *                    scaled and converted.
  976.      * @see         java.awt.Image
  977.      * @see         java.awt.image.ImageObserver
  978.      * @see         java.awt.image.ImageObserver#imageUpdate(java.awt.Image, int, int, int, int, int)
  979.      * @since       JDK1.1
  980.      */
  981.     public abstract boolean drawImage(Image img,
  982.                       int dx1, int dy1, int dx2, int dy2,
  983.                       int sx1, int sy1, int sx2, int sy2,
  984.                       ImageObserver observer);
  985.  
  986.     /**
  987.      * Draws as much of the specified area of the specified image as is
  988.      * currently available, scaling it on the fly to fit inside the
  989.      * specified area of the destination drawable surface. 
  990.      * <p>
  991.      * Transparent pixels are drawn in the specified background color. 
  992.      * This operation is equivalent to filling a rectangle of the
  993.      * width and height of the specified image with the given color and then
  994.      * drawing the image on top of it, but possibly more efficient.
  995.      * <p>
  996.      * This method returns immediately in all cases, even if the
  997.      * image area to be drawn has not yet been scaled, dithered, and converted
  998.      * for the current output device.
  999.      * If the current output representation is not yet complete then
  1000.      * <code>drawImage</code> returns <code>false</code>. As more of
  1001.      * the image becomes available, the process that draws the image notifies 
  1002.      * the specified image observer.
  1003.      * <p>
  1004.      * This method always uses the unscaled version of the image
  1005.      * to render the scaled rectangle and performs the required
  1006.      * scaling on the fly. It does not use a cached, scaled version
  1007.      * of the image for this operation. Scaling of the image from source
  1008.      * to destination is performed such that the first coordinate
  1009.      * of the source rectangle is mapped to the first coordinate of
  1010.      * the destination rectangle, and the second source coordinate is
  1011.      * mapped to the second destination coordinate. The subimage is
  1012.      * scaled and flipped as needed to preserve those mappings.
  1013.      * @param       img the specified image to be drawn
  1014.      * @param       dx1 the <i>x</i> coordinate of the first corner of the
  1015.      *                    destination rectangle.
  1016.      * @param       dy1 the <i>y</i> coordinate of the first corner of the
  1017.      *                    destination rectangle.
  1018.      * @param       dx2 the <i>x</i> coordinate of the second corner of the
  1019.      *                    destination rectangle.
  1020.      * @param       dy2 the <i>y</i> coordinate of the second corner of the
  1021.      *                    destination rectangle.
  1022.      * @param       sx1 the <i>x</i> coordinate of the first corner of the
  1023.      *                    source rectangle.
  1024.      * @param       sy1 the <i>y</i> coordinate of the first corner of the
  1025.      *                    source rectangle.
  1026.      * @param       sx2 the <i>x</i> coordinate of the second corner of the
  1027.      *                    source rectangle.
  1028.      * @param       sy2 the <i>y</i> coordinate of the second corner of the
  1029.      *                    source rectangle.
  1030.      * @param       bgcolor the background color to paint under the
  1031.      *                    non-opaque portions of the image.
  1032.      * @param       observer object to be notified as more of the image is
  1033.      *                    scaled and converted.
  1034.      * @see         java.awt.Image
  1035.      * @see         java.awt.image.ImageObserver
  1036.      * @see         java.awt.image.ImageObserver#imageUpdate(java.awt.Image, int, int, int, int, int)
  1037.      * @since       JDK1.1
  1038.      */
  1039.     public abstract boolean drawImage(Image img,
  1040.                       int dx1, int dy1, int dx2, int dy2,
  1041.                       int sx1, int sy1, int sx2, int sy2,
  1042.                       Color bgcolor,
  1043.                       ImageObserver observer);
  1044.  
  1045.     /**
  1046.      * Disposes of this graphics context and releases 
  1047.      * any system resources that it is using. 
  1048.      * A <code>Graphics</code> object cannot be used after 
  1049.      * <code>dispose</code>has been called.
  1050.      * <p>
  1051.      * When a Java program runs, a large number of <code>Graphics</code>
  1052.      * objects can be created within a short time frame.
  1053.      * Although the finalization process of the garbage collector 
  1054.      * also disposes of the same system resources, it is preferable 
  1055.      * to manually free the associated resources by calling this
  1056.      * method rather than to rely on a finalization process which 
  1057.      * may not run to completion for a long period of time.
  1058.      * <p>
  1059.      * Graphics objects which are provided as arguments to the 
  1060.      * <code>paint</code> and <code>update</code> methods 
  1061.      * of components are automatically released by the system when 
  1062.      * those methods return. For efficiency, programmers should
  1063.      * call <code>dispose</code> when finished using
  1064.      * a <code>Graphics</code> object only if it was created 
  1065.      * directly from a component or another <code>Graphics</code> object.
  1066.      * @see         java.awt.Graphics#finalize
  1067.      * @see         java.awt.Component#paint
  1068.      * @see         java.awt.Component#update
  1069.      * @see         java.awt.Component#getGraphics
  1070.      * @see         java.awt.Graphics#create
  1071.      * @since       JDK1.0
  1072.      */
  1073.     public abstract void dispose();
  1074.  
  1075.     /**
  1076.      * Disposes of this graphics context once it is no longer referenced.
  1077.      * @see #dispose
  1078.      * @since JDK1.0
  1079.      */
  1080.     public void finalize() {
  1081.     dispose();
  1082.     }
  1083.  
  1084.     /**
  1085.      * Returns a <code>String</code> object representing this 
  1086.      *                        <code>Graphics</code> object's value.
  1087.      * @return       a string representation of this graphics context.
  1088.      * @since        JDK1.0
  1089.      */
  1090.     public String toString() {    
  1091.     return getClass().getName() + "[font=" + getFont() + ",color=" + getColor() + "]";
  1092.     }
  1093.  
  1094.     /**
  1095.      * @deprecated As of JDK version 1.1,
  1096.      * replaced by <code>getClipBounds()</code>.
  1097.      */
  1098.     public Rectangle getClipRect() {
  1099.     return getClipBounds();
  1100.     }
  1101. }
  1102.